package com.sgcc.sx.pmos.e_sx_mall.activity;


import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SPUtils;
import com.sgcc.sx.pmos.arouter.app.AppArouterPath;
import com.sgcc.sx.pmos.arouter.mall.MallArouterPath;
import com.sgcc.sx.pmos.common.base.MvpBaseActivity;
import com.sgcc.sx.pmos.common.bean.EventCenter;
import com.sgcc.sx.pmos.common.utils.ArguConstant;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.e_sx_mall.presenter.PlaceOrderPresenter;

import org.greenrobot.eventbus.EventBus;


/**
 * 套餐详情
 * <p>
 * android锚点定位 Android 实现锚点定位思路详解
 * http://www.qb5200.com/article/353138.html
 */
@Route(path = MallArouterPath.MALL_LACEORDER_SUCCESS)
//placeordersuccess
public class PlaceOrderSuccessActivity extends MvpBaseActivity {

    private TitleBar mTitleBar;
    private TextView go_order, back_home,title_txt,content_txt;
    private TextView time_txt,name_txt;
    boolean isNow;
    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_placeorder_success;
    }

    @Override
    protected PlaceOrderPresenter createPresenter() {
        return new PlaceOrderPresenter();
    }

    @Override
    public boolean isBindEventBusHere() {
        return true;
    }

    @Override
    public void onEventCallBack(EventCenter eventCenter) {
        super.onEventCallBack(eventCenter);
        switch (eventCenter.getEventCode()) {
            case ArguConstant.PLACEORDER_GO_POWERSET:

                break;

        }
    }

    @Override
    protected void initViews() {
        super.initViews();
       isNow=  getIntent().getBooleanExtra("isNow",false);
//        pow_set_linear = findViewById(R.id.pow_set_linear);
        go_order= findViewById(R.id.go_order);
        back_home= findViewById(R.id.back_home);
        title_txt= findViewById(R.id.title_txt);
        content_txt= findViewById(R.id.content_txt);

        time_txt= findViewById(R.id.time_txt);
        name_txt= findViewById(R.id.name_txt);
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mTitleBar.ivBack.setVisibility(View.GONE);
        mTitleBar.setTitle("下单成功");
        mTitleBar.setRightIcon(R.mipmap.go_main, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goMainActivity();
            }
        });
        go_order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(isNow){
                    SPUtils.getInstance().put("order_success","contract");
                }else {
                    SPUtils.getInstance().put("order_success","order");
                }
                ARouter.getInstance()
                        .build(AppArouterPath.APP_MAIN)
                        .navigation();
                EventBus.getDefault().post(new EventCenter<>(ArguConstant.GO_ORDER));
            }
        });
        back_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance()
                        .build(AppArouterPath.APP_MAIN)
                        .navigation();
            }
        });
        if(isNow){
            go_order.setText("查看合约");
            title_txt.setText("合约签订成功");
            content_txt.setVisibility(View.GONE);
            time_txt.setVisibility(View.VISIBLE);
            name_txt.setVisibility(View.VISIBLE);
            time_txt.setText("合约周期："+getIntent().getStringExtra("dateStr"));
            name_txt.setText("店铺名称："+getIntent().getStringExtra("storeName"));
        }else{
            go_order.setText("查看订单");
            mTitleBar.setTitle("议价下单");
            time_txt.setVisibility(View.GONE);
            name_txt.setVisibility(View.GONE);
        }
//        aPackage = (PackageBean) intent.getSerializableExtra("package");


    }


}
